package com.sumer.psychology.common.resource;

import org.apache.commons.configuration.CompositeConfiguration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.HashMap;
import java.util.Map;

/**
 * 第三方系统集成
 * <p/>
 * Created by twer on 15/7/1.
 */
@Path("/v1/thirdparty/")
public class ThirdPartyResource extends AbstractResource {
    private static Logger logger = LoggerFactory.getLogger(ThirdPartyResource.class);
    private static final Map<Object, Object> Path_Map = new HashMap<>();

    static {
        CompositeConfiguration config = new CompositeConfiguration();
        try {
            config.addConfiguration(new PropertiesConfiguration("thirdparty.properties"));
            Path_Map.put("share", config.getString("sumer_share"));
            Path_Map.put("medal", config.getString("sumer_medal"));
            Path_Map.put("group", config.getString("sumer_group"));
            Path_Map.put("course", config.getString("sumer_course"));
            Path_Map.put("collect", config.getString("sumer_collect"));
        } catch (ConfigurationException e) {
            logger.error(e.getMessage());
        }
    }

    @GET
    @Path("paths/")
    @Produces(MediaType.APPLICATION_JSON)
    public Response getThirdPartyPath() {
        return Response.ok(Path_Map).build();
    }
}
